1 // Fig. 15.11: stack_c.h 2 // Definition of Stack class composed of List object 3 #ifndef STACK_C 4 #define STACK_C 5 #include "list.h" 6 7 template< class STACKTYPE > 8 class Stack { 9 public: 10 // no constructor; List constructor does initialization 11 void push( const STACKTYPE &d ) { s.insertAtFront( d ); } 12 bool pop( STACKTYPE &d ) { return s.removeFromFront( d ); } 13 bool isStackEmpty() const { return s.isEmpty(); } 14 void printStack() const { s.print(); } 15 private: 16 List< STACKTYPE > s; 17 }; 18 19 #endif